import axios from '@/services/index';

/** 租户列表接口 */
interface SearchType {
    pageNo: number;
    pageSize: number;
    companyName: string;
    contact: string;
    tel: string;
}

export interface UserData {
    /** 租户id */
    id: string;
    /** 租户名 */
    name: string;
    /** 法人名 */
    legalPerson: string;
    /** 经营状态 */
    statue:'1' | '2' | '3';
    /** 联系电话 */
    tel: string;
    /** 所属行业 */
    business: string;
    /** 邮箱 */
    email: string;
    /** 组织结构代码 */
    organizationCode: string;
    /** 统一信用代码 */
    creditCode: string;
    /** 工商注册号 */
    industryNum: string;
}

export interface UserListData {
    list: UserData[];
    total: number;
}

export async function getUserListService(params: SearchType) {
    const result = (await axios.post('/userList', params)) as UserListData;
    return result;
}

/** 删除租户 */
export async function delUserService(id: string) {
    const result = await axios.post('/delUser', {id});    
    return result;
}

/** 批量删除租户 */
export async function batchDelUserService(ids: React.Key[]) {
    const result = await axios.post('/batchDelUser', {ids});    
    return result;
}

/** 修改/新增租户 */
export async function editUserService(data: UserData) {
    const result = await axios.post('/editUser', data) as string;    
    return result;
}